package gold.contest;

import gold.utils.InputUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC5814 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int addRungs(int[] rungs, int dist) {
            int prev = 0, need = 0;
            for (int rung : rungs) {
                if (rung - prev > dist) {
                    int needLen = (rung - prev) / dist;
                    boolean curMod = (rung - prev) % dist == 0;
                    need += curMod ? needLen - 1 : needLen;
                }

                prev = rung;
            }

            return need;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[3]");
        System.out.println(solution.addRungs(arr, 1));
    }

    public static void main(String[] args) throws Exception {
        LC5814 an = new LC5814();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
